package cn.study.luckyapp.rule.command;

import cn.study.luckyapp.assembler.RuleAssembler;
import cn.study.luckyclient.dto.RuleUpdateCmd;
import cn.study.luckyclient.dto.data.RuleVo;
import cn.study.luckydomain.gateway.RuleGateway;
import cn.study.luckydomain.rule.RuleEntity;
import lombok.AllArgsConstructor;
import org.springframework.stereotype.Component;

@AllArgsConstructor
@Component
public class RuleUpdateCmdExe {
    private final RuleGateway ruleGateway;
    public RuleVo execute(RuleUpdateCmd cmd){
        RuleEntity ruleEntity = RuleAssembler.toEntity(cmd);
        RuleEntity update = ruleGateway.update(ruleEntity);
        return RuleAssembler.toRuleVo(update);
    }
}
